<template>
	<view :style="themeColor">
		<view class="page">
			<view class="flex align-stretch benben-position-layout flex address_flex_0"
				:style="{height:(88+StatusBarRpx)+'rpx',paddingTop:StatusBarRpx+'rpx', }">
				<view class='flex align-center justify-between flex-sub address_fd0_0'>
					<view class='flex align-center address_fd0_0_c0' @tap.stop="handleJumpDiy" data-type="back"
						data-url="1">
						<text class='fu-iconfont2  address_fd0_0_c0_c0'>&#xE794;</text>
					</view>
					<view class='flex align-center'>
						<text class='address_fd0_0_c1_c0'>{{$t('地址管理')}}</text>
					</view>
					<view class='flex align-center address_fd0_0_c0'>
					</view>
				</view>
			</view>
			<view :style="{height: (88+StatusBarRpx)+'rpx'}"></view>
			<view class="flex flex-direction align-stretch benben-flex-layout address_flex_1">
				<template v-for='(item,key0) in dataList'>
					<view class='flex flex-direction align-stretch address_fd1_0' @tap.stop="handleClickFunc(item.aid)"
						:key='key0'>
						<view class='flex flex-direction align-stretch'>
							<view class='flex flex-wrap align-center address_fd1_0_c0_c0'>
								<view
									class='flex flex-wrap align-center self-center justify-center address_fd1_0_c0_c0_c0'>
									<text class='self-center address_fd1_0_c0_c0_c0_c0'>{{item.label_name}}</text>
								</view>
								<text class='address_fd1_0_c0_c0_c1'>{{item.real_name}}</text>
								<text class='address_fd1_0_c0_c0_c2'>(</text>
								<text class='address_fd1_0_c0_c0_c2' v-if="item.sex=='1'">先生</text><text
									class='address_fd1_0_c0_c0_c2' v-if="item.sex!='1'">女士</text>
								<text class='address_fd1_0_c0_c0_c2'>)</text>
								<text class='flex-sub address_fd1_0_c0_c0_c5'>{{item.mobile}}</text>
							</view>
							<view>
								<text class='address_fd1_0_c0_c1_c0'>{{item.province}}</text>
								<text class='address_fd1_0_c0_c1_c0'>{{item.city}}</text>
								<text class='address_fd1_0_c0_c1_c0'>{{item.district}}</text>
								<text class='address_fd1_0_c0_c1_c0'>{{item.detail}}</text>
							</view>
							<view class='flex align-center justify-between address_fd1_0_c0_c2'>
								<view class='flex flex-wrap align-center'
									@tap.stop="SelectDefaultFunc(item.aid,item.is_default)">
									<image class='address_fd1_0_c0_c2_c0_c0' mode="aspectFit" :src='STATIC_URL+"3.png"'
										v-if="item.is_default=='1'"></image>
									<image class='address_fd1_0_c0_c2_c0_c0' mode="aspectFit"
										:src='STATIC_URL+"135.png"' v-if="item.is_default=='0'"></image>
									<text class='address_fd1_0_c0_c2_c0_c1'>{{$t('默认地址')}}</text>
								</view>
								<view class='flex flex-wrap align-center'>
									<view class='flex flex-wrap align-center' @tap.stop="getAddressIdFunc(item.aid)">
										<image class='address_fd1_0_c0_c2_c1_c0_c0' mode="aspectFit"
											:src='STATIC_URL+"6.png"'></image>
										<text class='address_fd1_0_c0_c2_c1_c0_c1'>{{$t('删除')}}</text>
									</view>
									<view class='flex flex-wrap align-center address_fd1_0_c0_c2_c1_c1'
										@tap.stop="handleJumpDiy" data-type="navigateTo"
										:data-url="`/pages/wd/editAddress/editAddress?id=${item.aid}`">
										<image class='address_fd1_0_c0_c2_c1_c0_c0' mode="aspectFit"
											:src='STATIC_URL+"7.png"'></image>
										<text class='address_fd1_0_c0_c2_c1_c0_c1'>{{$t('编辑')}}</text>
									</view>
								</view>
							</view>
						</view>
					</view>
				</template>
				<fu-empty :pagingListLoadedAll="pagingListLoadedAll" :pagingListNoListData="pagingListNoListData"
					:listDataLength="listDataLength" :isLoadInit="isLoadInit"></fu-empty>
				<view class='flex flex-wrap align-center justify-center address_fd1_1'>
					<button class='address_fd1_1_c0' @tap.stop="handleJumpDiy" data-type="navigateTo"
						:data-url="`/pages/wd/editAddress/editAddress`">{{$t('添加地址')}}</button>
				</view>
			</view>


			<benben-popup v-model="popupShow1661425659576" :mask="true" :mask-close-able="true" mode='center'>
				<!---删除地址弹窗flex布局开始-->
				<view class="flex flex-direction flex-wrap align-center address_flex_2">
					<text class='address_fd2_0'>{{$t('提示')}}</text>
					<text class='address_fd2_1'>{{$t('确定删除地址？')}}</text>
					<view class='flex align-center address_fd2_2'>
						<button class='address_fd2_2_c0' @tap.stop="popupShow1661425659576=false">{{$t('删除')}}</button>
						<button class='address_fd2_2_c1' @tap.stop="deleteAddressFunc()">{{$t('确定')}}</button>
					</view>
				</view>

				<!---删除地址弹窗flex布局结束-->

			</benben-popup>


		</view>
	</view>
</template>
<script>
	import pagingList from '@/common/mixin/paging_list.js';
	import {
		validate
	} from '@/common/utils/validate.js'

	export default {
		components: {},
		mixins: [pagingList],

		data() {
			return {
				"popupShow1661425659576": false,
				"minixPagingListsApi": "",
				"pageingListApiMethod": "",
				"allowOnloadGetList": false,
				"dataList": [],
				"sex_name": "",
				"address_ids": "",
				"switch_id": "",
				"is_change": ""
			};
		},
		computed: {
			themeColor() {
				return this.$store.getters.themeColor
			},

		},
		watch: {},
		onLoad(options) {
			let {
				is_change
			} = options
			if (is_change !== undefined) this.is_change = is_change
		},
		onUnload() {

		},
		onReady() {

		},
		onShow() {
			this.getListFunc()
		},
		onHide() {

		},
		onResize() {

		},
		onPullDownRefresh() {
			this.getListFunc()
		},
		onReachBottom(e) {

		},
		onPageScroll(e) {

		},
		methods: {
			//抛出选择的地址
			handleClickFunc(aid) {
				if (this.is_change == '1') {
					this.switch_id = aid;
					uni.$emit('isokaddid', this.switch_id)
					setTimeout(() => {
						this.$urouter.navigateBack(1);
					}, 500)
				}
			},
			//地址管理-地址列表
			getListFunc() {
				this.minixPagingListsApi = global.apiUrls.post636f7683cf195;
				this.pageingListApiMethod = 'get';
				this.allowOnloadGetList = false;
				this.pagingListPostDataContent = {}
				this.listData = [];
				this.dataList = this.listData;
				this.pagingListToggle();

			},
			//获取地址id
			getAddressIdFunc(id) {
				this.address_ids = id;
				this.popupShow1661425659576 = true;
			},
			//删除地址
			async deleteAddressFunc() {
				//请求方法
				//数据验证

				let data636f773e8d763 = await this.$api.post(global.apiUrls.post636f773e8d763, {
					address_id: this.address_ids
				});

				if (data636f773e8d763.data.code != 1) {
					this.$message.info(data636f773e8d763.data.msg);
					return
				}



				this.popupShow1661425659576 = false;
				this.getListFunc()
			},
			//选择默认
			async SelectDefaultFunc(defaulitID, defaulitid) {
				if (defaulitid == 0) {
					this.dataList.forEach(item => {
						item.is_default = 0
					})
					//请求方法
					//数据验证

					let data6389ad65f28d9 = await this.$api.post(global.apiUrls.post6389ad65f28d9, {
						address_id: defaulitID
					});

					if (data6389ad65f28d9.data.code != 1) {
						this.$message.info(data6389ad65f28d9.data.msg);
						return
					}



					this.dataList.forEach(item => {
						if (item.aid == defaulitID) {
							item.is_default = 1
						}
					})
					uni.showToast({
						title: global.i18n.t('设置成功'),
						mask: true,
						icon: 'none',
						duration: 1500
					});
				}
			},
			pagingListPostData() {
				return this.pagingListPostDataContent
			}
		}
	};
</script>
<style lang="scss" scoped>
	.page {
		width: 100vw;
		overflow-x: hidden;
		min-height: calc(100vh - var(--window-bottom));
		background: #F8F8F8;
		background-size: 100% auto;
	}

	.address_flex_0 {
		background: #fff;
		width: 750rpx;
		height: 88rpx;
		overflow: hidden;
		z-index: 10;
		top: 0rpx;
		background-size: 100% auto !important;
	}

	.address_fd0_0_c1_c0 {
		font-size: 36rpx;
		font-weight: 500;
		color: #333;
	}

	.address_fd0_0_c0_c0 {
		font-size: 32rpx;
		font-weight: 500;
		color: #333;
	}

	.address_fd0_0_c0 {
		width: 180rpx;
	}

	.address_fd0_0 {
		padding: 0rpx 32rpx 0rpx 32rpx;
		line-height: 88rpx;
	}

	.address_flex_1 {
		border-top: 1px solid #F6F7F9;
		margin: 0rpx 0rpx 20rpx 0rpx;
		padding: 0rpx 0rpx 150rpx 0rpx;
	}

	.address_fd1_1_c0 {
		background: var(--benbenbgColor7);
		border-radius: 44rpx 44rpx 44rpx 44rpx;
		font-size: 32rpx;
		color: rgba(255, 255, 255, 1);
		width: 686rpx;
		height: 88rpx;
		line-height: 88rpx;
		font-weight: 400;
	}

	.address_fd1_1 {
		width: 750rpx;
		position: fixed;
		left: 0rpx;
		bottom: calc(40rpx + var(--window-bottom));
	}

	.address_fd1_0_c0_c2_c1_c1 {
		margin: 0rpx 0rpx 0rpx 67rpx;
	}

	.address_fd1_0_c0_c2_c1_c0_c1 {
		line-height: 28rpx;
		font-size: 28rpx;
		font-weight: 400;
		color: #666666;
	}

	.address_fd1_0_c0_c2_c1_c0_c0 {
		width: 30rpx;
		height: 30rpx;
		border-radius: 0rpx 0rpx 0rpx 0rpx;
		margin: 0rpx 12rpx 0rpx 0rpx;
	}

	.address_fd1_0_c0_c2_c0_c1 {
		line-height: 32rpx;
		font-size: 28rpx;
		font-weight: 400;
		color: rgba(102, 102, 102, 1);
	}

	.address_fd1_0_c0_c2_c0_c0 {
		width: 36rpx;
		height: 36rpx;
		margin: 0rpx 14rpx 0rpx 0rpx;
	}

	.address_fd1_0_c0_c2 {
		border-top: 1px solid #eee;
		padding: 26rpx 0rpx 0rpx 0rpx;
		margin: 24rpx 0rpx 0rpx 0rpx;
	}

	.address_fd1_0_c0_c1_c0 {
		line-height: 40rpx;
		font-size: 28rpx;
		font-weight: 400;
		color: #666666;
	}

	.address_fd1_0_c0_c0_c5 {
		line-height: 40rpx;
		font-size: 28rpx;
		font-weight: 400;
		color: #1A1A1A;
		margin: 0rpx 0rpx 0rpx 24rpx;
		-webkit-line-clamp: 1;
		overflow: hidden;
		text-overflow: ellipsis;
		display: -webkit-box;
		-webkit-box-orient: vertical;
	}

	.address_fd1_0_c0_c0_c2 {
		line-height: 40rpx;
		font-size: 28rpx;
		font-weight: 400;
		color: #1A1A1A;
	}

	.address_fd1_0_c0_c0_c1 {
		line-height: 40rpx;
		font-size: 28rpx;
		font-weight: 400;
		color: #1A1A1A;
		max-width: 290rpx;
		-webkit-line-clamp: 1;
		overflow: hidden;
		text-overflow: ellipsis;
		display: -webkit-box;
		-webkit-box-orient: vertical;
	}

	.address_fd1_0_c0_c0_c0_c0 {
		color: var(--benbenFontColor4);
		font-size: 22rpx;
		font-weight: 400;
	}

	.address_fd1_0_c0_c0_c0 {
		border: 1px solid rgba(38, 114, 246, 1);
		background: rgba(242, 247, 255, 1);
		border-radius: 4rpx 4rpx 4rpx 4rpx;
		padding: 2rpx 10rpx 2rpx 10rpx;
		margin: 0rpx 14rpx 0rpx 0rpx;
	}

	.address_fd1_0_c0_c0 {
		padding: 0rpx 0rpx 20rpx 0rpx;
	}

	.address_fd1_0 {
		border: 1px solid #eee;
		background: var(--benbenbgColor1);
		padding: 30rpx 32rpx 20rpx 32rpx;
		background-size: 100% auto !important;
		margin: 0rpx 0rpx 20rpx 0rpx;
	}

	.address_flex_2 {
		background: #fff;
		margin: 0rpx 105rpx 0rpx 105rpx;
		background-size: #eee;
		border-radius: 25rpx 25rpx 25rpx 25rpx;
		padding: 40rpx 0rpx 0rpx 0rpx;
	}

	.address_fd2_2_c1 {
		background: var(--benbenbgColor1);
		line-height: 110rpx;
		border-radius: 0rpx 0rpx 16rpx 0rpx;
		font-size: 32rpx;
		color: var(--benbenFontColor5);
		width: 270rpx;
		height: 110rpx;
	}

	.address_fd2_2_c0 {
		border-right: 1px solid #EEEEEE;
		background: transparent;
		border-radius: 0rpx 0rpx 0rpx 16rpx;
		font-size: 32rpx;
		color: rgba(153, 153, 153, 1);
		height: 110rpx;
		line-height: 110rpx;
		width: 270rpx;
	}

	.address_fd2_2 {
		border-top: 1px solid #eee;
	}

	.address_fd2_1 {
		font-size: 32rpx;
		font-weight: 400;
		line-height: 52rpx;
		color: #333333;
		margin: 40rpx 0rpx 39rpx 0rpx;
	}

	.address_fd2_0 {
		color: #333333;
		font-size: 32rpx;
		font-weight: 500;
		line-height: 45rpx;
	}
</style>